Skip to content

Conversation

@nasahlpa
Copy link
Member

After a byte-wise copy using randomized_bytecopy() use the function consttime_memeq_byte() to check if copying the data was successful. This is a FI mitigation.

Closes #28753.

@nasahlpa nasahlpa requested a review from a team as a code owner November 19, 2025 08:02
@nasahlpa nasahlpa requested review from alees24 and removed request for a team November 19, 2025 08:02
@nasahlpa nasahlpa added the CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0 label Nov 19, 2025
Copy link
Contributor

@johannheyszl johannheyszl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nasahlpa !

After a byte-wise copy using randomized_bytecopy() use the function
consttime_memeq_byte() to check if copying the data was successful.
This is a FI mitigation.

Closes lowRISC#28753.

Signed-off-by: Pascal Nasahl <[email protected]>
Copy link
Contributor

@h-filali h-filali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nasahlpa for adding this!

Do we think we should randomize consttime_memeq_byte as well to avoid leakage?

To reduce SCA leakage, randomize the order we are reading from the
two buffers. This is in-line with other functions in `hardened_memory`.

Signed-off-by: Pascal Nasahl <[email protected]>
@nasahlpa
Copy link
Member Author

Thanks @nasahlpa for adding this!

Do we think we should randomize consttime_memeq_byte as well to avoid leakage?

Thanks Hakim - yes this is a good point.

I've pushed another commit that does the randomization of the consttime_memeq_byte function. @johannheyszl @h-filali could you please take a look into this commit as well.

Copy link
Contributor

@h-filali h-filali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nasahlpa. Checked out the second commit and this LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[crypto] Do memeq in randomized_bytecopy

4 participants